home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / intmail2 / pop2main.pas < prev    next >
Pascal/Delphi Source File  |  1999-07-21  |  2KB  |  69 lines

  1. unit Pop2Main;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   StdCtrls, msmsg, Mssocket, Mspop, ComCtrls;
  8.  
  9. type
  10.   TForm1 = class(TForm)
  11.     Label1: TLabel;
  12.     Label2: TLabel;
  13.     Label3: TLabel;
  14.     ServerEdit: TEdit;
  15.     UserNameEdit: TEdit;
  16.     PasswordEdit: TEdit;
  17.     BodyMemo: TMemo;
  18.     msPOPClient1: TmsPOPClient;
  19.     msMessage1: TmsMessage;
  20.     RetrieveButton: TButton;
  21.     procedure RetrieveButtonClick(Sender: TObject);
  22.   private
  23.     { Private declarations }
  24.   public
  25.     { Public declarations }
  26.   end;
  27.  
  28. var
  29.   Form1: TForm1;
  30.  
  31. implementation
  32.  
  33. {$R *.DFM}
  34.  
  35. procedure TForm1.RetrieveButtonClick(Sender: TObject);
  36. var
  37.   i: Integer;
  38.   Found: boolean;
  39. begin
  40.   msPOPClient1.Host:=ServerEdit.Text;
  41.   msPOPClient1.UserName:=UserNameEdit.Text;
  42.   msPOPClient1.Password:=PasswordEdit.Text;
  43.   msPOPClient1.Login;
  44.   if msPOPClient1.TotalMessages>0 then
  45.   begin
  46.     Found:=false;
  47.     for i:=0 to msPOPClient1.TotalMessages-1 do
  48.     begin
  49.       msPOPClient1.CurrentMessage:=i;
  50.       msPOPClient1.RetrieveHeaders;
  51.       Found:=Pos('camping',LowerCase(msMessage1.Subject))>0;
  52.       if Found then Break;
  53.     end;
  54.     if Found then
  55.     begin
  56.       msPOPClient1.CurrentMessage:=i;
  57.       msPOPClient1.Retrieve;
  58.       BodyMemo.Lines:=msMessage1.Body;
  59.     end
  60.     else
  61.       ShowMessage('Message not found');
  62.   end
  63.   else
  64.     ShowMessage('There are no messages');
  65.   msPOPClient1.Logout;
  66. end;
  67.  
  68. end.
  69.